﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="orgbody.aspx.cs" Inherits="ZX.WebApp.Message.orgbody" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
 
</title>
     <style type="text/css">
       
        textarea 
        {
            height:100px;
        }
        
        label
        {
            font-size:14px;
            text-align:right;
            width:200px;
        }
       body
       {
            background: #eeeeee;
       }
       
       td
       {
           border:1px sild #ddd;
       }       
    </style>
    <link rel="stylesheet" type="text/css" href="../Styles/default/calendar.css" /><link href="../Styles/base.css" rel="stylesheet" type="text/css" /><link href="../Styles/formReForm.css" rel="stylesheet" type="text/css" />
 
    <script src="../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.json-2.2.js" type="text/javascript"></script>
    <script src="../Scripts/Jquery.form.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.calendar.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.upload.js" type="text/javascript"></script>
    <script src="../Scripts/CombinButton.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script src="../Scripts/formReForm.js" type="text/javascript"></script>
    <script src="../Scripts/Appjs/CheckModel.js" type="text/javascript"></script>
 
</head>
<body >
    <form method="post" action="../Extend/AutoEditUI.aspx?r=0.3574855808415882&amp;entity=MQOrgBody" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="" />
</div>
    <div class="fieldForm" id="fieldForm">
        <table id="EditForm">
            <tr>
                <td valign='top' id="Col0">
                    <table>
                        <tr>
                            <td class='label'>
                                <label id="lab93d95f46-8ea5-577f-8271-3011730413ff" name="Xing">
                                    姓</label>
                            </td>
                            <td id="tdXing">
                                <input id="Xing" name="Xing" type="text" value="" class="yui-text" dtype="T" style="width: 250px"
                                    requiretype="1" />
                            </td>
                        </tr>
                        <tr>
                            <td class='label'>
                                <label id="lab6eaaef82-4870-6785-764f-53e2aa219b20" name="Ming">
                                    名</label>
                            </td>
                            <td id="tdMing">
                                <input id="Ming" name="Ming" type="text" value="" class="yui-text" dtype="T" style="width: 250px"
                                    requiretype="1" />
                            </td>
                        </tr>
                        <tr>
                            <td class='label'>
                                <label id="lab408de2f8-a53a-7057-753c-5a8f4afdffec" name="NiCheng">
                                    昵称</label>
                            </td>
                            <td id="tdNiCheng">
                                <input id="NiCheng" name="NiCheng" type="text" value="" class="yui-text" dtype="T"
                                    style="width: 250px" requiretype="0" />
                            </td>
                        </tr>
                        <tr>
                            <td class='label'>
                                <label id="laba788bec9-8714-8372-b12a-5afdc3b0019a" name="ShouJi">
                                    手机</label>
                            </td>
                            <td id="tdShouJi">
                                <input id="ShouJi" name="ShouJi" type="text" value="" class="yui-text" dtype="T"
                                    style="width: 250px" requiretype="1" />
                            </td>
                        </tr>
                        <tr>
                            <td class='label'>
                                <label id="lab93d95f46-8ea5-977f-8271-3011730413ff" name="email">
                                    邮箱</label>
                            </td>
                            <td id="tdemail">
                                <input id="email" name="email" type="text" value="" class="yui-text" dtype="T" style="width: 250px"
                                    requiretype="0" />
                            </td>
                        </tr>
                        <tr>
                            <td class='label'>
                                <label id="lab6eaaef82-4870-0785-764f-53e2aa219b20" name="GongSi">
                                    公司</label>
                            </td>
                            <td id="tdGongSi">
                                <input id="GongSi" name="GongSi" type="text" value="" class="yui-text" dtype="T"
                                    style="width: 250px" requiretype="0" />
                            </td>
                        </tr>
                        <tr>
                            <td class='label'>
                                <label id="lab408de2f8-a53a-1057-753c-5a8f4afdffec" name="ZhiYe">
                                    职业</label>
                            </td>
                            <td id="tdZhiYe">
                                <input id="ZhiYe" name="ZhiYe" type="text" value="" class="yui-text" dtype="T" style="width: 250px"
                                    requiretype="0" />
                            </td>
                        </tr>
                        <tr style='display: none'>
                            <td class='label'>
                                <label id="laba788bec9-8714-2372-b12a-5afdc3b0019a" name="otid">
                                    otid</label>
                            </td>
                            <td id="tdotid">
                                <input id="otid" name="otid" type="text" value="" class="yui-text" dtype="T" style="width: 250px"
                                       requiretype="0" />
                            </td>
                        </tr>
                        <tr style='display: none'>
                            <td class='label'>
                                <label id="lab93d95f46-8ea5-377f-8271-3011730413ff" name="AddUser">
                                    添加人</label>
                            </td>
                            <td id="tdAddUser">
                                <input id="AddUser" name="AddUser" type="text" value="" class="yui-text" dtype="T"
                                    style="width: 250px" requiretype="0" />
                            </td>
                        </tr>
                        <tr style='display: none'>
                            <td class='label'>
                                <label id="laba788bec9-8714-4372-b12a-5a3dc3b0019a" name="AddTime">
                                    日期</label>
                            </td>
                            <td id="tdAddTime">
                                <input id="AddTime" name="AddTime" type="text" value="" class="yui-date" dtype="D"
                                    style="width: 250px" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    </form>
    <form id="form2" action="../Extend/AjaxData/DataSave.aspx">
    <textarea style="display: none" id="jsonDataContent" rows="2" cols="2" name="jsonDataContent"></textarea>
    </form>
    <p>
</body>
<script type="text/javascript">
    var _domain = this.location.host;
    //var _href =  _domain.split('/');
    //alert(_href);
    //window.open();
    var url = "http://" + _domain + "/Extend/AjaxData/DataSave.aspx",
        entity = "MQOrgBody";
    var Parent = parent;
    //alert(url);
    var instance = [{ "obid": "00000000-0000-0000-0000-000000000000", "Xing": "", "Ming": "", "NiCheng": "", "ShengRi": "0001-01-01 ", "ShouJi": "", "email": "", "qq": "0", "msn": "", "weibo": "", "AiHao": "", "GongSi": "", "ZhiYe": "", "TongXinDiZhi": "", "YouBian": "", "AddUser": "00000000-0000-0000-0000-000000000000", "AddTime": "0001-01-01 "}];

    //alert(instance[0].EntityName);

    ///-------------------------------------
    ///供调用方法
    ///-------------------------------------
    function Save()
    {
        //debugger
        if (checkInputData() == "0")
        {
            return;
        }

        if (typeof (fnCustomSave) == "function")
        {
            fnCustomSave();
            return;
        }

        if (typeof (trySave) == "function")
        {
            setValue();
            var json = $.toJSON(instance[0]).replace(/'/g, "[B]");
            //var json =$.toJSON(instance[0]).replace(/'/g,"[B]").replace(/\n/g,'[BR]');
            $("#jsonDataContent").val(json);
            trySave();
            return;
        }


        fnSystemSave();
    }
    //只取一个URL参数：
    var queryString = function (key)
    {
        return (document.location.search.match(new RegExp("(?:^\\?|&)" + key + "=(.*?)(?=&|$)")) || ['', null])[1];
    }
    ///------------------------------------
    //系统的保存方法
    ///------------------------------------
    var action = 'insert';
    function setValue()
    {
        instance[0].Xing = $('#Xing').val();
        instance[0].Ming = $('#Ming').val();
        instance[0].NiCheng = $('#NiCheng').val();
        instance[0].ShouJi = $('#ShouJi').val();
        instance[0].email = $('#email').val();
        instance[0].GongSi = $('#GongSi').val();
        instance[0].ZhiYe = $('#ZhiYe').val();
        instance[0].otid = queryString("typeid");
        instance[0].AddUser = $('#AddUser').val();
        instance[0].AddTime = $('#AddTime').val();

        //instance[0]= $("form1").extractObject(); 
    }
    function fnSystemSave()
    {

        ///初始化相关参数
        setValue();
        $("#jsonDataContent").val($.toJSON(instance[0]));
        var SaveUrl = url + "?r=" + Math.random() + "&entity=" + entity + "&action=" + action + "&json=" + encodeURI($("#jsonDataContent").val().replace(/&/g, "[A]").replace(/'/g, "[B]"));
        if (typeof (checkData) == "function")
        {
            if (checkData() == "0")
            {
                return;
            }
        }

        ///调用验证
        if (typeof (fnCheckData) == "function")
        {
            var msg = fnCheckData(instance[0]);
            if (!msg == "")
            {
                alert(msg);
                return;
            }
        }
        
        //发送保存请求
        YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
            success: responseSuccess
                ,
            failure: responseFailure
        }, null);
    }

    ///初始化相关信息
    $(document).ready(function ()
    {
        $('#AddTime').cld();

        ///编辑状态
        if (getPar1("id") != "")
        {
            $("#form1").JSONToForm($.toJSON(instance[0]));
        }
        showMessage();
    });

    var formReForm;
    function doReform()
    {
        // load the css
        formReForm = new FormReForm('fieldForm');
        //formReForm.loadformReFormCss();

        // do the reform with default settings
        formReForm.doReForm();

    }


    var trySave = function ()
    {

        // argument formId can be the id or name attribute value of the
        // HTML form, or an HTML form object.
        var formObject = document.getElementById('form2');
        YAHOO.util.Connect.setForm(formObject);
        // This example facilitates a POST transaction.  The POST data(HTML form)
        // are initialized when calling setForm(), and it is automatically
        // included when calling asyncRequest.
        var cObj = YAHOO.util.Connect.asyncRequest('POST', url + "?flag=1&action=" + action + "&entity=" + entity, callback);
    }

    var responseSuccess = function (res)
    {
        try
        {
            var str = res.responseText;
            //var obj = eval(str);
            if (str == "1")
            {
                alert("数据保存成功");
                if (action == 'insert')
                {
                    //parent.fnAddRow(instance[0]);
                    parent.ReLoadData();
                } else
                {
                    parent.ReLoadData();
                    //parent.fnUpdateRow(instance[0]);
                }
                parent.closeWin();
            }
            else
            {
                if (str != "")
                {
                    showMessage();
                    alert(str + "\n" + "数据保存失败!");
                }
            }
        }
        catch (e)
        {
        }
        finally
        {
        }
    };

    var responseFailure = function (error)
    {
        //alert("数据错误：" + error.statusText);
    }

    // Create a callback object that defines success and failure
    // handlers, and instructs Connection Manager to use the
    // Flash transport by defining the xdr property and setting
    // it to true.
    var callback = {
        success: responseSuccess,
        failure: responseFailure
    };

    var SetControlValue = function (o)
    {
        $.each(o, function (property, value)
        {
            //try {
            value = value + "";
            // find the control and set value
            if (property != "")
            {
                var control = $("[name='" + property + "']");
                var strValue = value.replace(/@1@1@1/g, "'");
                strValue = strValue.replace(/@2@2@2/g, '"');
                strValue = strValue.replace(/@@@@/g, "\n");
                strValue = strValue.replace(/[BR]/g, "\n");
                control.val(strValue);
                try
                {
                    $('#' + property).combobox('setValue', strValue);
                } catch (Error) { }
            }
            //  };
        });
    }
</script>
<script type="text/javascript" language="javascript">
    //调用初始化控件功能
    if (typeof (fnInitControl) == "function")
    {
        fnInitControl();
    }
</script>
</html>
